package com.zqh.synchronizedDemo;

/**
 * @author 曾庆红
 * {@code @date} 2023-10-11 18:11
 * 同步和非同步方法是否可以同时调用
 */
public class T3 {
    public synchronized void m1(){
        System.out.println(Thread.currentThread().getName()+ " m1 start...");
        try{
            Thread.sleep(10000);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+ " m1 end...");
    }
    public void m2(){
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + " m2 ");
    }

    public static void main(String[] args) {
        T3 t = new T3();

        new Thread(t::m1,"t1").start();
        new Thread(t::m2,"t2").start();

    }
}
